package com.example.wan1.view.collect;

import com.example.wan1.R;
import com.example.wan1.adapter.CollectWebAdapter;
import com.example.wan1.adapter.MixedAdapter;
import com.example.wan1.adapter.ShareAdapter;
import com.example.wan1.base.adapter.SubPagerAdapter;
import com.example.wan1.di.ano.ActivityScope;
import com.example.wan1.di.ano.FragmentScope;
import com.example.wan1.model.ArticleBean;
import com.example.wan1.model.CollectWebBean;
import com.example.wan1.model.MixedEntity;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;

/***
 * @Author: zxd
 * @CreateDate: 2020/8/26 13:04
 * @Description: 收藏:界面和碎片没有同时实现接口，所以可以写在一起
 */
@Module
public abstract class CollectModule {
    //activity
    @ActivityScope
    @Provides
    static SubPagerAdapter provideFragmentAdapter(CollectActivity activity) {
        return new SubPagerAdapter(activity.getSupportFragmentManager(),
                BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }

    /*@Provides
    static SubPagerAdapter provideFragmentAdapter(SimpleActivity activity) {
        return new SubPagerAdapter(activity.getSupportFragmentManager(),
                BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }*/

    @ActivityScope
    @Provides
    static List<String> provideFragmentTitleList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static List<Fragment> provideFragmentList() {
        return new ArrayList<>();
    }

    //碎片
    @Binds
    abstract CollectContract.View collectFragmentView(PerCollectFragment perCollectFragment);

    @FragmentScope
    @Provides
    static CollectWebAdapter provideAdapter(List<CollectWebBean> mList) {
        return new CollectWebAdapter(R.layout.collect_web_item, mList);
    }

    @FragmentScope
    @Provides
    static List<CollectWebBean> provideList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static ShareAdapter provideShareAdapter(List<ArticleBean> mList) {
        return new ShareAdapter(R.layout.share_item, mList);
    }

    @FragmentScope
    @Provides
    static List<ArticleBean> provideShareList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static MixedAdapter provideMixedAdapter(List<MixedEntity> mList) {
        return new MixedAdapter(mList);
    }

    @FragmentScope
    @Provides
    static List<MixedEntity> provideMixedList() {
        return new ArrayList<>();
    }
}
